<script setup lang="ts">
import { onMounted, ref } from 'vue'
import type { GoodsType } from '@/apis/components/goodsType'
import { getLikeListAPI } from '@/apis/user'
import GoodsItem from '@/view/Home/components/GoodsItem.vue'
import { useUserStore } from '@/stores/store'

const userStore = useUserStore()

// 猜你喜欢数据列表
const likeList = ref<[GoodsType]>()
// 获取猜你喜欢数据
const getLikeList = async () => {
  const res = await getLikeListAPI(4)
  likeList.value = res.data.result
}

onMounted(() => getLikeList())
</script>

<template>
  <div class="box">
    <div class="top">
      <div class="userInfo">
        <img :src="userStore.userInfo?.avatar" alt="" />
        <p>{{ userStore.userInfo?.account }}</p>
      </div>
      <div class="to">
        <p>会员中心</p>
        <p>安全设置</p>
        <p>地址管理</p>
      </div>
    </div>
    <div class="down">
      <p>猜你喜欢</p>
      <ul>
        <li v-for="item in likeList" :key="item.id">
          <GoodsItem :goods="item" />
        </li>
      </ul>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.box {
  width: 997px;
  height: 600px;
  border: 1px solid rgba(0, 0, 0, 0.126);
  margin-left: 20px;
  .top {
    width: 1000px;
    height: 130px;
    background: url('@/asset/images/center-bg.png') no-repeat;
    display: flex;
    justify-content: space-between;
    .userInfo {
      width: 300px;
      height: 100%;
      display: flex;
      justify-content: space-evenly;
      align-items: center;
      img {
        width: 100px;
        height: 100px;
        border-radius: 50%;
      }
      p {
        width: 150px;
        height: 100%;
        color: white;
        line-height: 130px;
        text-align: center;
        font-size: 18px;
      }
    }
    .to {
      width: 400px;
      height: 100%;
      display: flex;
      justify-content: space-around;
      p {
        width: 80px;
        width: 100%;
        line-height: 130px;
        text-align: center;
        color: white;
        cursor: pointer;
      }
    }
  }
  .down {
    width: 100%;
    height: 400px;
    margin-top: 30px;
    p {
      width: 120px;
      height: 30px;
      text-align: center;
      line-height: 30px;
      font-size: 20px;
    }
    ul {
      width: 100%;
      height: 300px;
      display: flex;
      justify-content: space-evenly;
      margin-top: 50px;
      li {
        list-style: none;
      }
    }
  }
}
</style>
